"""
使用if语句处理列表
"""
print("--------------5.1 使用if语句处理列表-----------------")
requested_toppings = ['mushrooms', 'green peppers', 'extra cheese']

for requested_topping in requested_toppings:
    if requested_topping == 'green peppers':
        print("Sorry, we are out of green peppers right now.")
    else:
        print("Adding " + requested_topping + ".")
    print("Adding " + requested_topping + ".")

print("\nFinished making your pizza!")

print("--------------5.2 确定列表非空-----------------")
requested_toppings = []

# 列表非空时，执行if代码块，否则执行else代码块
# 对于数值0，空值 None, 单引号空字符串 ''，双引号空字符串 ""，
# 空字典 {}，空元组 ()，空列表 []，Python都会返回False
if requested_toppings:
    # 非空时，执行for循环
    for requested_topping in requested_toppings:
        print("Adding " + requested_topping + ".")
else:
    print("Are you sure you want a plain pizza?")
    print("\nFinished making your pizza!")

print("--------------5.3 使用多个列表-----------------")
# 使用多个列表,定义可用的配料列表
available_toppings = ['mushrooms', 'olives', 'green peppers',
                      'pepperoni', 'pineapple', 'extra cheese']
# 定义顾客点的配料列表
requested_toppings = ['mushrooms', 'french fries', 'extra cheese']
# 遍历顾客点的配料列表
for requested_topping in requested_toppings:
    # 判断顾客点的配料是否在可用配料列表中
    if requested_topping in available_toppings:
        print("Adding " + requested_topping + ".")
    else:
        print("Sorry, we don't have " + requested_topping + ".")

print("\nFinished making your pizza!")